﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QYmall.Core.Model.ViewModels
{
    /// <summary>
    /// 订单发票(显示)
    /// </summary>
    public class OrderInvoiceDto : OrderInvoiceEditDto
    {
        /// <summary>
        /// 自增ID
        /// </summary>
        [Display(Name = "自增ID")]
        public long Id { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [Display(Name = "创建人")]
        [StringLength(128)]
        public string? AddBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        public DateTime AddTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 已删除：0否1是
        /// </summary>
        [Display(Name = "状态")]
        [Range(0, 9)]
        public byte IsDelete { get; set; } = 0;

        /// <summary>
        /// 订单号
        /// </summary>
        [Display(Name = "订单号")]
        [StringLength(128)]
        public string? OrderNo { get; set; }

        /// <summary>
        /// 快递公司信息
        /// </summary>
        public ShopExpressDto? Express { get; set; }
    }

    /// <summary>
    /// 订单发票(编辑)
    /// </summary>
    public class OrderInvoiceEditDto
    {
        /// <summary>
        /// 所属商户ID
        /// </summary>
        [Display(Name = "所属商户")]
        public int MerchantId { get; set; }

        /// <summary>
        /// 所属订单ID
        /// </summary>
        [Display(Name = "所属订单")]
        public long OrderId { get; set; }

        /// <summary>
        /// 发票台头
        /// </summary>
        [Display(Name = "发票台头")]
        [StringLength(30)]
        public string? InvoiceTitle { get; set; }

        /// <summary>
        /// 发票类型
        /// </summary>
        [Display(Name = "发票类型")]
        [Range(0, 9)]
        public int? InvoiceType { get; set; }

        /// <summary>
        /// 发票金额
        /// </summary>
        [Display(Name = "发票金额")]
        [Column(TypeName = "decimal(18, 2)")]
        public decimal InvoiceAmount { get; set; } = 0M;

        /// <summary>
        /// 税号
        /// </summary>
        [Display(Name = "税号")]
        [StringLength(128)]
        public string? DutyParagraph { get; set; }

        /// <summary>
        /// 发票号
        /// </summary>
        [Display(Name = "发票号")]
        [StringLength(30)]
        public string? InvoiceNumber { get; set; }

        /// <summary>
        /// 收货人姓名
        /// </summary>
        [Display(Name = "收货人")]
        [Required(ErrorMessage = "{0}不可为空")]
        [StringLength(30)]
        public string? AcceptName { get; set; }

        /// <summary>
        /// 固定电话
        /// </summary>
        [Display(Name = "固定电话")]
        [StringLength(30)]
        public string? TelPhone { get; set; }

        /// <summary>
        /// 手机号码
        /// </summary>
        [Display(Name = "手机号码")]
        [Required(ErrorMessage = "{0}不可为空")]
        [RegularExpression(@"^(13|14|15|16|18|19|17)\d{9}$")]
        [StringLength(30)]
        public string? Mobile { get; set; }

        /// <summary>
        /// 省份名称
        /// </summary>
        [Display(Name = "所属省份")]
        [Required(ErrorMessage = "{0}不可为空")]
        [StringLength(128)]
        public string? Province { get; set; }

        /// <summary>
        /// 城市名称
        /// </summary>
        [Display(Name = "所属城市")]
        [Required(ErrorMessage = "{0}不可为空")]
        [StringLength(128)]
        public string? City { get; set; }

        /// <summary>
        /// 所属地区
        /// </summary>
        [Display(Name = "所属地区")]
        [Required(ErrorMessage = "{0}不可为空")]
        [StringLength(128)]
        public string? Area { get; set; }

        /// <summary>
        /// 详细地址
        /// </summary>
        [Display(Name = "详细地址")]
        [Required(ErrorMessage = "{0}不可为空")]
        [StringLength(512)]
        public string? Address { get; set; }

        [Display(Name = "运费")]
        [Column(TypeName = "decimal(18, 2)")]
        public decimal Freight { get; set; } = 0M;

        [Display(Name = "快递公司")]
        public int ExpressId { get; set; }

        [Display(Name = "快递单号")]
        [Required(ErrorMessage = "{0}不可为空")]
        [StringLength(128)]
        public string? ExpressCode { get; set; }

        [Display(Name = "备注说明")]
        [StringLength(512)]
        public string? Remark { get; set; }


        /// <summary>
        /// 订单商品列表
        /// </summary>
        public ICollection<OrderInvoiceGoodsDto> InvoiceGoods { get; set; } = new List<OrderInvoiceGoodsDto>();
    }
}
